home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Messaging / OSL / OSLToken.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  3.6 KB  |  143 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OSLToken.c
  3.  
  4.     Contains:    Routines for manipulating OSLTokens
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <6>     5/21/95    NP        1248898: GetUserToken, ODDescToAEDesc, etc.
  13.                                     recipe change.
  14.          <5>      5/3/95    NP        1211084: Remove 5$
  15.          <4>      2/8/95    NP        1218550: Don't allocate OSLContexts
  16.                                     dynamically.
  17.          <3>    11/15/94    NP        1196322,1199847-made functions non-pascal,
  18.                                     changed implementation for new tokens.
  19.          <2>     8/19/94    NP        1181622: Ownership fix.
  20.          <5>     9/24/93    JA        Minor syntactic tweaks for THINK C++.
  21.          <4>     8/25/93    NP        Fixed bugs: routines returning garbage.
  22.          <3>     8/19/93    NP        Changed name of error code.
  23.          <2>     8/16/93    NP        Adjusted for latest OSL proposal.
  24.          <1>     8/11/93    NP        first checked in
  25.  
  26.     To Do:
  27. */
  28.  
  29. #pragma segment OSLToken
  30.  
  31. #ifndef _OSLTOKEN_
  32. #include "OSLToken.h"
  33. #endif
  34.  
  35. void StuffContextIntoToken(OSLToken* token, OSLContext context);
  36. OSLContext GetContextFromToken(const OSLToken* token);
  37.  
  38. #pragma lib_export on
  39.  
  40. #if 0
  41. OSErr OSLGetAppTokenDesc(OSLToken* token, AEDesc* appDesc)
  42. {
  43.     appDesc->descriptorType = token->descriptorType;
  44.     appDesc->dataHandle = token->dataHandle;
  45.     return noErr;
  46. }
  47.  
  48. OSErr OSLPutAppTokenDesc(OSLToken* token, AEDesc* appDesc)
  49. {
  50.     token->descriptorType = appDesc->descriptorType;
  51.     token->dataHandle = appDesc->dataHandle;
  52.     return noErr;
  53. }
  54. #endif
  55. DescType OSLGetTokenDescType(const OSLToken* token)
  56. {
  57.     return token->descriptorType;
  58. }
  59.  
  60. void OSLSetTokenDescType(OSLToken* token, DescType appDescType)
  61. {
  62.     token->descriptorType = appDescType;
  63. }
  64.  
  65. Handle OSLGetTokenDataHandle(const OSLToken* token)
  66. {
  67.     return token->dataHandle;
  68. }
  69.  
  70. void OSLSetTokenDataHandle(OSLToken* token, Handle appHandle)
  71. {
  72.     token->dataHandle = appHandle;
  73. }
  74.  
  75. //$$$$$ These next two routines should put the context data at the beginning
  76. //    of the token. Make necessary changes in NamRslvr as well.
  77.  
  78. //------------------------------------------------------------------------------
  79. // StuffContextIntoToken
  80. //------------------------------------------------------------------------------
  81.  
  82. void StuffContextIntoToken(OSLToken* token, OSLContext context)
  83. {
  84.     *(OSLContext*)(((char*)(*(token->dataHandle))) + sizeof(long)) = context;
  85. }
  86.  
  87. //------------------------------------------------------------------------------
  88. // GetContextFromToken
  89. //------------------------------------------------------------------------------
  90.  
  91. OSLContext GetContextFromToken(const OSLToken* token)
  92. {
  93.     return *(OSLContext*)(((char*)(*(token->dataHandle))) + sizeof(long));
  94. }
  95.  
  96. //------------------------------------------------------------------------------
  97. // OSLGetTokenContext
  98. //------------------------------------------------------------------------------
  99.  
  100. OSErr OSLGetTokenContext(const OSLToken* token, OSLContext* context)
  101. {
  102.     if (!token->dataHandle)
  103.         return errNotAValidToken;
  104.     *context = GetContextFromToken(token);
  105.     return noErr;
  106. }
  107.  
  108. //------------------------------------------------------------------------------
  109. // OSLSetTokenContext
  110. //------------------------------------------------------------------------------
  111.  
  112. OSErr OSLSetTokenContext(OSLToken* token, OSLContext* context)
  113. {
  114.     if (!token->dataHandle)
  115.         return errNotAValidToken;
  116.     StuffContextIntoToken(token, *context);
  117.     return noErr;
  118. }
  119.  
  120.  
  121.  
  122. GetCallbackCallerProc OSLGetContextProc(const OSLContext* context)
  123. {
  124.     return context->getCallerProc;
  125. }
  126.  
  127. long OSLGetContextRefCon(const OSLContext* context)
  128. {
  129.     return context->refCon;
  130. }
  131.  
  132. void OSLSetContextProc(OSLContext* context,
  133.                                 GetCallbackCallerProc proc)
  134. {
  135.     context->getCallerProc = proc;
  136. }
  137.  
  138. void OSLSetContextRefCon(OSLContext* context, long refCon)
  139. {
  140.     context->refCon = refCon;
  141. }
  142.  
  143.